package lbhlll;




public class JoinDemo {

    static Object o1 = new Object();
    static Object o2 = new Object();
    static class l2 implements Runnable{
        @Override
        public void run() {
            synchronized (o1) {
                System.out.println("我总要说点什么2");
                try {
                    Thread.currentThread().wait();
                    System.out.println("线程2被唤醒");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    static class l1 implements Runnable{
        @Override
        public void run() {
            try {
                System.out.println("444444");
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                System.out.println("捕获到异常");
            }
            System.out.println("我还能继续运行吗");
        }
    }

    public static void main(String[] args) {
        l1 l1 = new l1();
        Thread thread = new Thread(l1);
        thread.start();
        try {
            Thread.sleep(2000);
            //睡眠2秒之后唤醒线程
            thread.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
